#include "src/test_scheme.h"
#include "src/examples.h"
#include <unistd.h> 
// CKKS基本算子测试
void TestCKKS(params param);


int main()
{    
    // //测试基本算子
    params param = params::logN15QP881;
    TestCKKS(param);

    //测试用例
    Examples::TestPolyMult();

    Examples::TestRotate();
    //测试自举
    Examples::TestBootStrapping();



    //测试自举
    // params param = params::logN12QP1725;
    // TestScheme::TestBootstrapping(12, 28, 4, 8, 53, 4, 11);
    // TestScheme::TestBootstrapping(15, 28, 4, 8, 53, 4, 14);

    return 0;
}


void TestCKKS(params param)
{
    long logN;// N的长度
    long qCount;// 模数Q的个数
    long pCount; // 模数P的个数
    long tCount; // 模数T的个数
    long logScale;// 缩放因子的精度
    int gamma;// 切片数
    long logSlot;// 槽的数
    switch (param) {
        case params::logN15QP891:
            logN = 15;
            qCount = 18;
            pCount = 6;
            tCount = 8;
            logScale = 36;
            gamma = 6;
            logSlot = 14;
            break;
        case params::logN12QP1725:
            logN = 12;
            qCount = 28;
            pCount = 4;
            tCount = 8;
            logScale = 53;
            gamma = 4;
            logSlot = 11;
            break;
        case params::logN15QP881:
            logN = 15;
            qCount = 15;
            pCount = 1;
            tCount = 5;
            logScale = 55;
            gamma = 4;
            logSlot = 14;
            break;
        case params::logN15QP1725:
            logN = 15;
            qCount = 28;
            pCount = 4;
            tCount = 8;
            logScale = 53;
            gamma = 4;
            logSlot = 14;
    }

    TestScheme::TestEncrypt(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

    TestScheme::TestAddPt(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

    TestScheme::TestAddCt(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

    TestScheme::TestMultPt(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

    TestScheme::TestMultCt(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

    TestScheme::TestRotateTime(logN, qCount, pCount, tCount, logScale, gamma, 37, logSlot, true);

    TestScheme::TestRotate(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

    TestScheme::TestSquare(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

    TestScheme::TestConjugateBatch(logN, qCount, pCount, tCount, logScale, gamma, logSlot);

}


